'use strict'

const { ApiController } = require('jax')

class Controller extends ApiController {
  async constant() {
    const { ctx } = this
    const CONSTANT = this.config.constant
    const returnData = {
      ...CONSTANT,
    }

    delete returnData.SYSTEM_TYPE_ADMIN
    delete returnData.SYSTEM_TYPE_PROJECT
    delete returnData.ADMIN_PASSWORD

    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }

  async dict() {
    const { ctx } = this
    const returnData = await this.service.dict.getDict()

    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }

  async show() {
    const { ctx } = this
    const { params } = ctx

    const returnData = await ctx.service.config.getConfigByType(params.configType, {
      isPublic: true,
    })

    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }
}

module.exports = Controller
